package graphicInterface;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;

import java.awt.FlowLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.BoxLayout;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.CardLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

import category.CategoryCollection;

import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import net.miginfocom.swing.MigLayout;
import com.jgoodies.forms.factories.FormFactory;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.SwingConstants;
import javax.swing.JMenu;

import recipie.core.Ingredient;
import recipie.core.IngredientCollection;
import recipie.core.MesureUnit;

public class GUI_PChef  extends JFrame{
	
	JPanel menu;
	JPanel central;
	
	IngredientCollection aI;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					GUI_PChef window = new GUI_PChef();
					window.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public GUI_PChef() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(1000, 700);
		getContentPane().setLayout(new BorderLayout());
		menu();
		getContentPane().add(menu,BorderLayout.WEST);
		central = new subGUI_logo();
		getContentPane().add(central,BorderLayout.CENTER);
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		
	}

	private void menu(){
		menu = new JPanel();
		menu.setAlignmentX(Component.LEFT_ALIGNMENT);
		JButton home = new JButton("HOME");
		home.setAlignmentX(Component.CENTER_ALIGNMENT);
		home.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0){
				getContentPane().remove(central);
				//central = new subGUI_logo();
				CategoryCollection c = new CategoryCollection();
				
				new GUI_AddCategory(c).setVisible(true);
				getContentPane().add(central,BorderLayout.CENTER);
			}
		});
		JButton new_recipies= new JButton("NEW");
		new_recipies.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0){
				getContentPane().remove(central);
				central = new subGUI_addIngr2Recipies(aI);
				getContentPane().add(central,BorderLayout.CENTER);
				getContentPane().validate();
			}
		});
		menu.setLayout(new GridLayout(0, 1, 0, 0));
		menu.add(home);
		JButton v_recipies= new JButton("RECIPIES");
		v_recipies.setAlignmentX(Component.CENTER_ALIGNMENT);
		v_recipies.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0){
				SwingUtilities.invokeLater(new Runnable(){
					@Override
					public void run(){
						getContentPane().remove(central);
						central= new subGUI_viewRecipies();
						getContentPane().add(central,BorderLayout.CENTER);
						getContentPane().validate();
					}
				});
			}
		});
		menu.add(v_recipies);
		menu.add(new_recipies);
	}
	
}
